home *** CD-ROM | disk | FTP | other *** search
- From jdc@naucse.cse.nau.edu Thu Mar 5 09:26:35 1992
- Return-Path: <jdc@naucse.cse.nau.edu>
- Received: from naucse.cse.nau.edu by ra-next.arc.nasa.gov (NeXT-1.0 (From Sendmail 5.52)/NeXT-1.0)
- id AA10623; Thu, 5 Mar 92 09:26:21 PST
- Received: by naucse.cse.nau.edu (5.65c/1.5-nau)
- id AA21522; Thu, 5 Mar 1992 10:32:12 -0700
- Message-Id: <199203051732.AA21522@naucse.cse.nau.edu>
- From: jdc@naucse.cse.nau.edu (John Campbell)
- Date: Thu, 5 Mar 1992 10:32:09 MST
- X-Mailer: Mail User's Shell (7.2.3 5/22/91)
- To: woo@ra-next.arc.nasa.gov
- Subject: gplotlib.shr1
- Status: R
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 5)."
- # Contents: 000alpha.notes 000announce Makefile Makefile.ult bar.doc
- # bar.t1 bar.t2 bar.t3 bar.t4 bar.t5 bar.t6 bar.t7 bars.c docu.c
- # getopt.c gsr.h gtplot.h gutil.c makefile.3b1 makefile.ult
- # makefile.unx
- # Wrapped by jdc@naucse.cse.nau.edu on Tue Feb 11 08:42:11 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f '000alpha.notes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'000alpha.notes'\"
- else
- echo shar: Extracting \"'000alpha.notes'\" \(2676 characters\)
- sed "s/^X//" >'000alpha.notes' <<'END_OF_FILE'
- X
- X000alpha.notes:
- X
- XInitial version --- jdc 3/19/90
- X
- XYou're looking at gplotlib--an accompaniment to gnuplot that I'm thinking
- Xabout posting someday. Put the files in this shar package into a directory
- Xcalled ``gplotlib'' under the normal gnuplot source directory. (This is to
- Xallow the Makefile to find ../term where the terminal routines are expected
- Xto live.)
- X
- XRight now the gplotlib library consists of two files: low level routines
- X(gterm.c), and "high level" routines (gsr.c). In addition, there is some
- Xdocumentation (make doc) and examples: bars.c (using low level routines only)
- Xand bar.c (using a mix of high and low level routines).
- X
- XThe "high level" routines are mostly untested. The assortment presented
- Xis merely those that appeared after mucking with the gnuplot graphics.c
- Xcode. Thus the library isn't really thought out or designed with any
- Xidea in mind that these are actually routines needed by users, rather they
- Xare just the routines that gnuplot itself would have probably needed if it
- Xhad been written with an underlying library in mind. Using these gsr
- Xroutines tends to create plots that look a lot like gnuplot plots.
- X
- XCertainly there is a lot of room for improvement here. Many design
- Xquestions arise: Should, for example, there be a gsr_draw_line()
- Xroutine? Or even, should there be a whole new direction or module
- Xof graphics support? One thing does seem true, however: with these
- Xroutines the terminal drivers are now at least available to programmers.
- X
- XThe bar.c program is not really finished. I'm not sure what else
- Xit needs, however, since I don't use bar charts myself. It provides
- Xa pragmatic example of using these two libraries in an intimate, but
- Xprobably not very clean, manner. I expect bar.c could profit from
- Xhaving better labels, and some method of assigning labels to the
- Xplot. Further, bars.c puts a small gap between the top of the highest
- Xbar and the boundary while bar.c does not do this.
- X
- XThe makefile mentions pie.c--which is going to be a pie chart graphics
- Xprogram. This hasn't, however, been written. I assume it too will
- Xbe a hodge-podge mix of gsr and gterm routines. In particular, the
- Xnumber of segments chosen to draw a circle will probably depend
- Xupon t->xmax and t->ymax to maximize the effect on a given terminal.
- X
- XWorking on various graphics projects is the only way I know to tell
- Xif we are getting at all close to a usable library package. I'm sure
- Xthere is a lot missing from this first edition... Any help or suggestions
- Xwould be greatly appreciated.
- X
- XJohn Campbell
- X...arizona!naucse!jdc
- X-or CAMPBELL@NAUVAX.bitnet
- X-or (for small mail items only)- ...arizona!naucse!thunde!jdc
- END_OF_FILE
- if test 2676 -ne `wc -c <'000alpha.notes'`; then
- echo shar: \"'000alpha.notes'\" unpacked with wrong size!
- fi
- # end of '000alpha.notes'
- fi
- if test -f '000announce' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'000announce'\"
- else
- echo shar: Extracting \"'000announce'\" \(1378 characters\)
- sed "s/^X//" >'000announce' <<'END_OF_FILE'
- X
- XThis is to solicit alpha users willing to look at an experimental
- Xgnuplot library I've created called gplotlib. At this point gplotlib
- Xis merely an experiment and there is no reason at all to think it will
- Xever make it into the gnuplot distribution. On the other hand, I did
- Xthe work hoping one day it might grow into something useful.
- X
- XGplotlib uses the terminal drivers and a slightly modified term.c
- Xpiece of code to provide programmers easy access to all those nice
- Xterminal drivers in gnuplot. A friend got me started on this with the
- Xidea of making graphs in a public domain spread sheet package. Right
- Xnow the only program written with this library is a bar chart program
- Xthat exists mostly to show how to use the library (although it does as
- Xpromised and will generate bar charts).
- X
- XDon't expect a very polished product right now. The documentation
- Xlives mostly in the source code and the makefiles are fairly untested.
- XStill, for an alpha package, it's not that horrible.
- X
- XDave Kotz was nice enough to give me space on his cs.duke.edu machine,
- Xso if you have ftp access you can pick this up as ~pub/gplotlib.tar.Z
- Xon cs.duke.edu. Otherwise you can ask for a shar file from me:
- X
- XThanks,
- X-------
- X John Campbell ...!arizona!naucse!jdc
- X CAMPBELL@NAUVAX.bitnet
- X unix? Sure send me a dozen, all different colors.
- END_OF_FILE
- if test 1378 -ne `wc -c <'000announce'`; then
- echo shar: \"'000announce'\" unpacked with wrong size!
- fi
- # end of '000announce'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(1658 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X#
- X# GNUPLOT Makefile for ATT 3b1 (ATT 7300 or the "unix-PC")
- X#
- X# Note: this makefile uses the shared library
- X#
- X
- X# Well, man page needs to be generated out of source code for library
- X# somehow...
- XMANDEST=/usr/man/manl
- X
- X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
- X# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
- X# -DNOCOPY if you don't have a memcpy() by any name
- X# -O if you trust your compiler's optimizer
- XCC = cc
- X
- XCFLAGS = -g -DNOCWDRC -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -I..
- X
- X#TERMFLAGS = -I../term -DUNIXPC
- XTERMFLAGS = -DUNIXPC
- X
- X# These object files form the gplotlib.ar library
- XOBJS = gsr.o gterm.o gutil.o ../bitmap.o
- X
- X# -lplot iff you have -DUNIXPLOT
- X# -lsuntool -lsunwindow -lpixrect iff you have -DSUN
- X# -lgl_s if IRIS4D
- XLIBS = -lm -lplot
- X
- Xbar: $(OBJS) bar.o
- X ld /lib/crt0s.o /lib/shlib.ifile bar.o $(OBJS) $(LIBS) -o bar
- X
- Xbars: $(OBJS) bars.o
- X ld /lib/crt0s.o /lib/shlib.ifile bars.o $(OBJS) $(LIBS) -o bars
- X
- Xpie: $(OBJS) pie.o
- X ld /lib/crt0s.o /lib/shlib.ifile pie.o $(OBJS) $(LIBS) -o pie
- X
- Xall: bar pie
- X
- Xgterm.o: ../term/*.trm gterm.c
- X $(CC) $(CFLAGS) $(TERMFLAGS) -c gterm.c
- X
- X$(OBJS): gtplot.h gsr.h
- X
- Xclean:
- X rm -f *.o *~ *.*_doc
- X
- Xspotless:
- X rm -f *.o *~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc
- X
- Xdoc: docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
- X docu <gsr.c >gsr.c_doc
- X docu <gsr.h >gsr.h_doc
- X docu <gterm.c >gterm.c_doc
- X docu <gtplot.h >gtplot.h_doc
- X cpr -ac -C -PBACKSPACE \
- X intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
- X rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc
- X
- Xdocu: docu.c
- X cc docu.c -o docu
- X
- Xcpr: cpr.c
- X cc cpr.c -o cpr
- X
- X
- END_OF_FILE
- if test 1658 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'Makefile.ult' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.ult'\"
- else
- echo shar: Extracting \"'Makefile.ult'\" \(3338 characters\)
- sed "s/^X//" >'Makefile.ult' <<'END_OF_FILE'
- X#
- X# GPLOTLIB Makefile for Ultrix
- X#
- X# Note: Ultrix standard cc compiler has a bug with static structure
- X# initializations [such as struct ts {int x;} tb[]={{100*0.32}};]
- X# and so this makefile uses vcc instead. If this isn't possible,
- X# and you get "line xx: illegal initialization", then you'll have
- X# to go into the .trm include file and compute all the floating point
- X# defines with a calculator.
- X
- X
- X# directory where to install executables on 'make install'
- XDEST=/usr/local/lib
- X# directory for installing man page on 'make man_install'
- X# Well, man page needs to be generated out of source code for library
- X# somehow...
- XMANDEST=/usr/man/manl
- X
- X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
- X# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
- X# -DNOCOPY if you don't have a memcpy() by any name
- X# -O if you trust your compiler's optimizer
- XCC = cc
- X
- XCFLAGS = -DBCOPY -DBZERO -O #-gx
- X
- X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
- X# -DAED AED 512 and AED 767
- X# -DAPOLLO Apollo workstations
- X# -DBITGRAPH BBN BitGraph
- X# -DDXY800A Roland DXY800A plotter
- X# -DEPSON Epson LX-800, Star NL-10, NX-1000 and lots of others
- X# -DFIG Fig graphics language (requires object.h from TransFig)
- X# -DHP2648 HP2648, HP2647
- X# -DHP26 HP2623A and maybe others
- X# -DHP75 HP7580, and probably other HPs
- X# -DHPGL HP7475 and (hopefully) lots of others
- X# -DHPLJET HP Laserjet
- X# -DIMAGEN Imagen laser printers (300dpi) (requires -Iterm also)
- X# -DIRIS4D IRIS4D series computer
- X# -DKERMIT MS-Kermit Tektronix 4010 emulator
- X# -DLATEX LATEX picture environment
- X# -DPOSTSCRIPT Postscript
- X# -DPROPRINTER IBM Proprinter
- X# -DQMS QMS/QUIC laserprinter (Talaris 1200 and others)
- X# -DREGIS ReGis graphics (vt125, vt220, vt240, Gigis...)
- X# -DSELANAR Selanar
- X# -DTEK Tektronix 4010, and probably others
- X# -DSUN Sun Microsystems Workstation
- X# -DUNIXPC unixpc (ATT 3b1 or ATT 7300)
- X# -DUNIXPLOT unixplot
- X# -DV384 Vectrix 384 and tandy color printer
- X
- X# -DEPSON removed just before HP2648.
- X
- XTERMFLAGS = -I../term -DAED -DBITGRAPH -DDXY800A -DHP2648 \
- X -DHP26 -DHP75 -DHPGL -DHPLJET -DIMAGEN -DKERMIT -DLATEX \
- X -DPOSTSCRIPT -DPROPRINTER -DQMS -DREGIS -DSELANAR -DTEK \
- X -DUNIXPLOT -DV384
- X
- X# These object files form the gplotlib.ar library
- XOBJS = gsr.o gterm.o
- X
- X# -lplot iff you have -DUNIXPLOT
- X# -lsuntool -lsunwindow -lpixrect iff you have -DSUN
- X# -lgl_s if IRIS4D
- XLIBS = -lm -lplot
- X
- Xbar: $(OBJS) bar.o
- X vcc bar.o $(OBJS) $(LIBS) -o bar
- X
- Xbars: $(OBJS) bars.o
- X vcc bars.o $(OBJS) $(LIBS) -o bar
- X
- Xpie: $(OBJS) pie.o
- X vcc pie.o $(OBJ) $(LIBS) -o bar
- X
- Xall: bar pie
- X
- Xgterm.o: ../term/*.trm gterm.c
- X vcc $(CFLAGS) $(TERMFLAGS) -c gterm.c
- X
- X$(OBJS): gtplot.h gsr.h
- X
- Xclean:
- X rm -f *.o *~ *.*_doc
- X
- Xspotless:
- X rm -f *.o *~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc
- X
- Xdoc: docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
- X docu <gsr.c >gsr.c_doc
- X docu <gsr.h >gsr.h_doc
- X docu <gterm.c >gterm.c_doc
- X docu <gtplot.h >gtplot.h_doc
- X cpr -ac -C -PBACKSPACE \
- X intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
- X rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc
- X
- Xdocu: docu.c
- X cc docu.c -o docu
- X
- Xcpr: cpr.c
- X cc cpr.c -o cpr
- END_OF_FILE
- if test 3338 -ne `wc -c <'Makefile.ult'`; then
- echo shar: \"'Makefile.ult'\" unpacked with wrong size!
- fi
- # end of 'Makefile.ult'
- fi
- if test -f 'bar.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.doc'\"
- else
- echo shar: Extracting \"'bar.doc'\" \(1167 characters\)
- sed "s/^X//" >'bar.doc' <<'END_OF_FILE'
- X
- X bar plots:
- X bar [-x xlabel] [-y ylabel] [-t title] [-T term] [file [file2 ...]]
- X
- X
- X data files look like the following:
- X
- X 100 20
- X 300
- X -40.5 35 290 297
- X
- X where each value on the line is a new bar and each line creates
- X a gap between bars and starts the pattern used by bars over again.
- X
- X Bar is really to demonstrate how to use the gplotlib library. Note
- X that bar assumes gt_term_init() can identify the terminal (graphics
- X device) to use to generate the bar plot. Some devices automatically
- X come up (eg Sun workstations) while others need to have the environment
- X variable GNUTERM set (eg GNUTERM=tek_40xx).
- X
- X For example, to plot the data in bar.t4 with labels to a NEC black and
- X white printer you would need to do the following (on unix):
- X
- X % GNUTERM=nec_cp6m
- X % bar -x months -y stocks -t "Nest Egg" bar.t4 >foo.out
- X % cat foo.out >/dev/rawlp
- X --or alternatively---
- X % bar -x months -y stocks -t Savings -Tnec_cp6m <bar.t4 >/dev/rawlp
- X
- X Note that the list of terminals recognized will probably be the same
- X as in gnuplot so you can say ``set terminal'' inside gnuplot to get
- X the list of known terminals.
- X
- END_OF_FILE
- if test 1167 -ne `wc -c <'bar.doc'`; then
- echo shar: \"'bar.doc'\" unpacked with wrong size!
- fi
- # end of 'bar.doc'
- fi
- if test -f 'bar.t1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t1'\"
- else
- echo shar: Extracting \"'bar.t1'\" \(25 characters\)
- sed "s/^X//" >'bar.t1' <<'END_OF_FILE'
- X100
- X20
- X300
- X40
- X35
- X290
- X297
- END_OF_FILE
- if test 25 -ne `wc -c <'bar.t1'`; then
- echo shar: \"'bar.t1'\" unpacked with wrong size!
- fi
- # end of 'bar.t1'
- fi
- if test -f 'bar.t2' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t2'\"
- else
- echo shar: Extracting \"'bar.t2'\" \(54 characters\)
- sed "s/^X//" >'bar.t2' <<'END_OF_FILE'
- X5
- X10
- X15
- X20
- X25
- X30
- X35
- X40
- X45
- X50
- X50
- X40
- X35
- X22
- X17
- X12
- X11
- X9
- X2
- END_OF_FILE
- if test 54 -ne `wc -c <'bar.t2'`; then
- echo shar: \"'bar.t2'\" unpacked with wrong size!
- fi
- # end of 'bar.t2'
- fi
- if test -f 'bar.t3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t3'\"
- else
- echo shar: Extracting \"'bar.t3'\" \(59 characters\)
- sed "s/^X//" >'bar.t3' <<'END_OF_FILE'
- X5
- X10
- X-15
- X20
- X25
- X30
- X35
- X-40
- X45
- X50
- X50
- X40
- X35
- X-22
- X17
- X-12
- X11
- X9
- X-2
- END_OF_FILE
- if test 59 -ne `wc -c <'bar.t3'`; then
- echo shar: \"'bar.t3'\" unpacked with wrong size!
- fi
- # end of 'bar.t3'
- fi
- if test -f 'bar.t4' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t4'\"
- else
- echo shar: Extracting \"'bar.t4'\" \(133 characters\)
- sed "s/^X//" >'bar.t4' <<'END_OF_FILE'
- X5 11 11
- X10 12 6
- X-15 2 5
- X20 7
- X25 20
- X30 12
- X35 11
- X-40 11 6 -10 -6 11
- X45 10
- X50 10
- X50 10
- X40 19
- X35 12
- X-22 13
- X17 13
- X-12 12
- X11 14
- X9 1
- X-2 -12
- END_OF_FILE
- if test 133 -ne `wc -c <'bar.t4'`; then
- echo shar: \"'bar.t4'\" unpacked with wrong size!
- fi
- # end of 'bar.t4'
- fi
- if test -f 'bar.t5' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t5'\"
- else
- echo shar: Extracting \"'bar.t5'\" \(66 characters\)
- sed "s/^X//" >'bar.t5' <<'END_OF_FILE'
- X10 12 3
- X20 7 20 5 10
- X25 20 11
- X35 11
- X45 10
- X50 10
- X40 19
- X35 12
- X17 13
- END_OF_FILE
- if test 66 -ne `wc -c <'bar.t5'`; then
- echo shar: \"'bar.t5'\" unpacked with wrong size!
- fi
- # end of 'bar.t5'
- fi
- if test -f 'bar.t6' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t6'\"
- else
- echo shar: Extracting \"'bar.t6'\" \(90 characters\)
- sed "s/^X//" >'bar.t6' <<'END_OF_FILE'
- X5 11 11 3 8 20 25 31 18
- X10 12 6 12 5 21
- X20 7 10 8 3 22
- X35 11 8 4 25 23
- X-40 11 6 -10 -6 11
- END_OF_FILE
- if test 90 -ne `wc -c <'bar.t6'`; then
- echo shar: \"'bar.t6'\" unpacked with wrong size!
- fi
- # end of 'bar.t6'
- fi
- if test -f 'bar.t7' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bar.t7'\"
- else
- echo shar: Extracting \"'bar.t7'\" \(105 characters\)
- sed "s/^X//" >'bar.t7' <<'END_OF_FILE'
- X.5 .11 .11
- X.10 .12 .6
- X.20 .7 .10
- X.35 .11 .08
- X-.1 .11 .6
- X.10 .02 .03
- X.03 -.10 .11
- X.07 .08 .09
- X.5 .03 .25
- END_OF_FILE
- if test 105 -ne `wc -c <'bar.t7'`; then
- echo shar: \"'bar.t7'\" unpacked with wrong size!
- fi
- # end of 'bar.t7'
- fi
- if test -f 'bars.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bars.c'\"
- else
- echo shar: Extracting \"'bars.c'\" \(6602 characters\)
- sed "s/^X//" >'bars.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <math.h>
- X#include "gtplot.h"
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X FILE *in, *fopen();
- X struct termentry *t;
- X
- X if (argc > 2)
- X usage();
- X
- X if (argc == 0)
- X in = stdin;
- X else if ((in = fopen (argv[1], "r")) == NULL) {
- X fprintf (stderr, "Can't open %s\n", argv[1]);
- X exit();
- X }
- X
- X GToutfile = stdout;
- X/*
- X still missing the signal handler--especially to make sure we
- X always reset the terminal before we leave on the signals that
- X gnuplot normally traps (2 of them).
- X*/
- X gt_init_terminal(); /* Hope we set term here--if not need too later. */
- X if (!GTterm) {
- X fprintf (stderr, "Sorry, unknown terminal type\n");
- X exit(1);
- X }
- X t = >term_tbl[GTterm];
- X#ifdef WAIT
- X gt_test_term();
- X#endif
- X bar_graph(in);
- X getchar();
- X (*t->reset)();
- X}
- X
- Xbar_graph(in)
- XFILE *in;
- X/*
- X Routine to make a bar graph out of a list of points. The list of
- X points come from the file named on the command line.
- X
- X Parameter:
- X
- X in: Pointer to file descriptor containing list of points.
- X*/
- X{
- X#define MAXBUF 255
- X struct termentry *t = >term_tbl[GTterm];
- X int *pnum, bar_w, x_loc, height, lcnt, max_points=t->xmax/2;
- X int err, i, k, result, bar_cnt=0;
- X float *pval, scale, pmax, pmin, dummy;
- X char buf[MAXBUF], *malloc();
- X
- X/* Read everything into an array of floats with room for 10 per line. */
- X pval = (float *)malloc (10*sizeof(float)*max_points);
- X pnum = (int *)malloc (sizeof(int )*max_points);
- X pmin = VERYLARGE;
- X pmax = -VERYLARGE;
- X err = 0;
- X for (lcnt=0; fgets (buf, MAXBUF, in) != NULL; ++lcnt) {
- X result = sscanf(buf,"%f %f %f %f %f %f %f %f %f %f %f",
- X &pval[lcnt*10], &pval[lcnt*10+1], &pval[lcnt*10+2], &pval[lcnt*10+3],
- X &pval[lcnt*10+4], &pval[lcnt*10+5], &pval[lcnt*10+6], &pval[lcnt*10+7],
- X &pval[lcnt*10+8], &pval[lcnt*10+9], &dummy);
- X if (result > 10) {
- X err = 1;
- X break;
- X }
- X /* Find the max and min of the overall array. */
- X for (k = 0; k < result; ++k) {
- X if (pval[lcnt*10+k] > pmax) pmax = pval[lcnt*10+k];
- X if (pval[lcnt*10+k] < pmin) pmin = pval[lcnt*10+k];
- X }
- X pnum[lcnt] = result; /* number of items on this line. */
- X bar_cnt += result;
- X if (bar_cnt > max_points) {
- X err = 1;
- X break;
- X }
- X }
- X if (bar_cnt >= max_points) {
- X fprintf (stderr, "Error on input: more than %d data elements\n", bar_cnt);
- X exit(1);
- X }
- X if (err) {
- X fprintf (stderr, "Error on input: line %d\n", lcnt);
- X exit(1);
- X }
- X
- X/* Draw the bars represented by the array pval. */
- X bar_draw (pval, pnum, lcnt, pmax, pmin);
- X}
- X
- X
- Xusage()
- X{
- X fprintf (stderr, "usage: bar [file]\n");
- X exit(1);
- X}
- X
- X
- X#define SOLID
- X
- Xbar_draw (pval, pnum, lcnt, pmax, pmin)
- Xfloat pval[], pmax, pmin;
- Xint pnum[], lcnt;
- X/*
- X Routine to draw the bars represented by values in array pval.
- X
- X Parameters:
- X
- X pval: array of groups of points to take as bar heights.
- X
- X pnum: array of the number of points in the ith bar group.
- X
- X lcnt: number of groups (10 at most per group) of bars to draw.
- X
- X pcnt: number of points to draw.
- X
- X pmax: largest value in the pval array.
- X
- X pmin: smallest value in the pval array.
- X*/
- X{
- X int i, j, k, bar_cnt, zero, y_loc, bar_h, bar_w, x_loc;
- X float scale, range, yoff=0.0;
- X struct termentry *t = >term_tbl[GTterm];
- X
- X#define GAP (t->v_char/2) /* Space between bar and top (or bott) of graph. */
- X
- X/* Compute scaling factor zero point, etc for this bar graph. */
- X if (pmin < 0.0) {
- X /* Make a gap at the top and at the bottom of the bar graph */
- X range = pmax - pmin;
- X scale = (t->ymax - 2*GAP)/range;
- X zero = (0.0-pmin) * scale + GAP + 0.5;
- X yoff = pmin - GAP/scale;
- X }
- X else {
- X /* Make a gap only at the top of the bar graph */
- X range = pmax;
- X scale = (t->ymax - GAP)/range;
- X zero = 0;
- X }
- X
- X/* Compute the width of the bar graph. */
- X for (bar_cnt=i=0; i < lcnt; ++i)
- X bar_cnt += pnum[i]+1;
- X
- X bar_w = t->xmax/bar_cnt;
- X
- X/* Compute start of first bar. */
- X x_loc = (t->xmax - (bar_cnt-1)*bar_w)/2.0 + 0.5;
- X
- X#ifdef DEBUG
- X for (i=0; i < lcnt; ++i) {
- X fprintf (stderr, "%d: pval[%d] = ", pnum[i], i*10);
- X for (k=0; k < pnum[i]; ++k) {
- X fprintf (stderr, "%f ", pval[i*10+k]);
- X }
- X fprintf (stderr,"\n");
- X }
- X fprintf (stderr, "lcnt = %d\t", lcnt);
- X fprintf (stderr, "scale = %f\t", scale);
- X fprintf (stderr, "pmax = %f\t", pmax);
- X fprintf (stderr, "pmin = %f\n", pmin);
- X fprintf (stderr, "zero = %d\t", zero);
- X fprintf (stderr, "bar_cnt = %d\n", bar_cnt);
- X fprintf (stderr, "bar_w = %d\n", bar_w);
- X fprintf (stderr, "Hit return\n");
- X (void )getchar();
- X#endif
- X
- X/* Put device into graphics mode. */
- X if (!GTterm_init) {
- X (*t->init)();
- X GTterm_init = TRUE;
- X }
- X (*t->graphics)(); /* Default linetype is 0 (solid line) */
- X
- X/* Draw a box around the plot. */
- X (*t->move)(0,0);
- X (*t->vector)(0,t->ymax-1);
- X (*t->vector)(t->xmax-1,t->ymax-1);
- X (*t->vector)(t->xmax-1, 0);
- X (*t->vector)(0,0);
- X
- X/* Draw the zero line. */
- X if (zero != 0) {
- X (*t->move)(x_loc,zero);
- X (*t->vector)(t->xmax-x_loc-1,zero);
- X }
- X
- X/* Draw lcnt bars of bar_h scale*pval[i] and width bar_w. */
- X for (i = 0; i < lcnt; ++i) {
- X for (k = 0; k < pnum[i]; ++k) {
- X bar_h = (int )((scale * (pval[i*10+k] - yoff)) + 0.5);
- X
- X#ifdef DEBUG
- X fprintf (stderr, "bar_h = %d, linetype = %d\n", bar_h, k);
- X#endif
- X
- X (*t->move)(x_loc,zero);
- X (*t->vector)(x_loc, bar_h);
- X (*t->vector)(x_loc+bar_w, bar_h);
- X (*t->vector)(x_loc+bar_w, zero);
- X#ifdef SOLID
- X if (k % 6 < 4) {
- X for (j=0; j < bar_w; ++j) {
- X /* Terminal drivers define points as unsigned int... */
- X (*t->move)(x_loc+j,zero);
- X if (j % (k % 4 + 1) == 0)
- X (*t->vector)(x_loc+j,bar_h);
- X }
- X }
- X else {
- X int lower, upper;
- X if (zero < bar_h) {
- X lower = zero;
- X upper = bar_h;
- X }
- X else {
- X lower = bar_h;
- X upper = zero;
- X }
- X for (j=lower; j < upper; ++j) {
- X if (j % (k % 3 + 1) == 0) {
- X (*t->move)(x_loc,j);
- X (*t->vector)(x_loc+bar_w,j);
- X }
- X }
- X }
- X#endif
- X x_loc += bar_w;
- X }
- X x_loc += bar_w;
- X }
- X/* Back into text mode (to see the plot generated) */
- X (*t->text)();
- X
- X}
- END_OF_FILE
- if test 6602 -ne `wc -c <'bars.c'`; then
- echo shar: \"'bars.c'\" unpacked with wrong size!
- fi
- # end of 'bars.c'
- fi
- if test -f 'docu.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'docu.c'\"
- else
- echo shar: Extracting \"'docu.c'\" \(5248 characters\)
- sed "s/^X//" >'docu.c' <<'END_OF_FILE'
- X#define EOF -1
- X#define MAXLINE 133
- X#define TEN 100
- X#define MAXTEN 13300
- X#define SPACE 3
- X#define CP_ int
- X
- X#include <stdio.h>
- X
- Xmain(argc, argv)
- Xint argc;
- XCP_ argv;
- X/*-
- X Routine to take stdin and create a document on stdout. A "document"
- X is all comments lines starting with /*- and ending with
- X*/
- X/*-
- X In addition, this program will also output up to 10 lines before the
- X /*- comment until a blank line is found (going in reverse up the document).
- X*/
- X{
- X/* Variables
- X comment- Value 0 means no comment seen yet, value 1 comment, value 2 end.
- X*/
- X int i, comment, top, end_of_file, empty, blanks, save, nlines;
- X char buffer[MAXTEN];
- X
- X#ifdef VMS
- X redirect(&argc,argv,0); /* - redirect standard I/O (from chj) */
- X#endif
- X
- X if (argc != 1) useage();
- X
- X comment = 0;
- X empty = 0;
- X save = 0;
- X top = TEN;
- X
- X
- X do {
- X end_of_file = fillup (buffer, MAXLINE, TEN, save, &nlines);
- X /* Cycle through the current buffer, locate top. */
- X
- X for (top = top + save - TEN, i = save; i < nlines; i++) {
- X test (buffer+MAXLINE*i, MAXLINE, &empty, &comment);
- X if (comment > 0) {
- X for (; top < i; top++)
- X putout (buffer+MAXLINE*top, MAXLINE);
- X top = TEN;
- X putout (buffer+MAXLINE*i, MAXLINE);
- X save = 0;
- X }
- X if (comment == 2) {
- X putspace (SPACE);
- X top = i+1;
- X }
- X if (comment == 0) save++;
- X if (empty && comment == 0) top = i + 1;
- X
- X /* Save the least number of lines necessary. */
- X save = TEN - top > save ? save : TEN - top;
- X
- X /* Be sure that at least one new line is read in. */
- X save = save >= TEN ? TEN - 1 : save;
- X }
- X } while (end_of_file != EOF);
- X
- X exit(0);
- X}
- X
- X
- Xdocopy (src, dst, max)
- Xchar *src, *dst;
- Xint max;
- X/*-
- X Routine to copy src to dst up to and including the '\n' character,
- X not more than max characters will be copied, however.
- X-*/
- X{
- X while (*src != '\n' && max--)
- X *dst++ = *src++;
- X *dst = '\n';
- X}
- X
- X
- Xerror (string)
- Xchar *string;
- X/*-
- X Routine to print a string and then die.
- X-*/
- X{
- X while (*string) putchar(*string++);
- X putchar('\n');
- X}
- X
- X
- Xfillup (buffer, maxline, size, save, nlines)
- Xchar *buffer;
- Xint maxline, size, save, *nlines;
- X/*-
- X Routine to fill a buffer at offsets maxline for size lines from stdin.
- X The buffer will "slide" up by size-save number of lines (eg save = 4 means
- X that the last 4 lines will become the top 4 lines).
- X
- X Parameters:
- X
- X buffer: maxline*size character array.
- X
- X maxline: length of longest line (until a '\n' is seen).
- X
- X size: number of lines the buffer can hold.
- X
- X save: number of lines from previous buffer to save as top lines
- X of this new buffer.
- X
- X nlines: number of active lines in this buffer (returned).
- X-*/
- X{
- X int line, count;
- X char *ptr;
- X
- X line = 0;
- X count = 0;
- X
- X/* Save the bottom lines by rearranging them as the top lines. */
- X for (line = 0; line < save; line++)
- X docopy (buffer+maxline*(size-save+line), buffer+maxline*line, maxline);
- X
- X/* Read in some more lines. fgets fills in up to maxline characters. */
- X while (line < size &&
- X (ptr = fgets(&buffer[maxline*line++], maxline, stdin)) != NULL);
- X
- X/* Return the number of active lines in the buffer. */
- X *nlines = line;
- X return (ptr == NULL ? EOF : 1); /* eof tested in calling routine */
- X}
- X
- X
- Xputout (buffer, maxline)
- Xchar *buffer;
- Xint maxline;
- X/*-
- X Routine to put the buffer out to stdout until either maxline is
- X reached or a newline is reached.
- X-*/
- X{
- X do {
- X putchar (*buffer);
- X if (*buffer++ == '\n')
- X return;
- X } while (maxline--);
- X}
- X
- X
- Xputspace (space)
- Xint space;
- X/*-
- X Routine to put space around each seperate comment block.
- X-*/
- X{
- X putchar ('\n');
- X while (space--)
- X putchar('-');
- X putchar ('\n');
- X}
- X
- X
- Xtest (buffer, maxline, empty, comment)
- Xchar *buffer;
- Xint maxline, *empty, *comment;
- X/*-
- X Routine to test buffer and determine if it is empty (all white space)
- X or if comment should toggle. Comment is set to 1 when it is 0 and then
- X a run of /*- is seen. Comment is set to 0 when it is 1 and a closing
- X 'C' comment is seen, like this:
- X*/
- X{
- X if (*comment == 2)
- X *comment = 0; /* Turn off comment indicator */
- X
- X *empty = 1;
- X while (*buffer == ' ' || *buffer == '\t' || *buffer == '\n') {
- X maxline--;
- X if (*buffer == '\n' || maxline == 0)
- X return;
- X buffer++;
- X }
- X
- X/* buffer now points at a non-blank character. */
- X *empty = 0;
- X
- X/* Check to see if start of comment is anywhere on this line. */
- X while (*(buffer+1) != '\n' && maxline > 0) {
- X if (*buffer == '/' && *(buffer+1) == '*' && *(buffer+2) == '-')
- X *comment = 1;
- X if (*comment == 1 && *buffer == '*' && *(buffer+1) == '/')
- X *comment = 2;
- X buffer++;
- X maxline--;
- X }
- X}
- X
- X
- Xuseage()
- X/*-
- X Explain the useage of docu:
- X
- X docu <stdin >stdout
- X
- X (strips document comments out of 'C' code)
- X*/
- X{
- X static char *mess1 = "docu <stdin >stdout",
- X *mess2 = "(strips document comments out of 'C' code)";
- X
- X while (*mess1) putchar (*mess1++);
- X putchar('\n');
- X while (*mess2) putchar (*mess2++);
- X putchar ('\n');
- X exit(1);
- X}
- END_OF_FILE
- if test 5248 -ne `wc -c <'docu.c'`; then
- echo shar: \"'docu.c'\" unpacked with wrong size!
- fi
- # end of 'docu.c'
- fi
- if test -f 'getopt.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'getopt.c'\"
- else
- echo shar: Extracting \"'getopt.c'\" \(1552 characters\)
- sed "s/^X//" >'getopt.c' <<'END_OF_FILE'
- X/*
- X * getopt - get option letter from argv
- X * This software is in the public domain
- X * Originally written by Henry Spencer at the U. of Toronto
- X */
- X
- X#include <stdio.h>
- X
- Xchar *optarg; /* Global argument pointer. */
- Xint optind = 0; /* Global argv index. */
- X
- Xstatic char *scan = NULL; /* Private scan pointer. */
- X
- X/* extern char *index(); obsolete, used strchr (JDC). */
- X
- Xint
- Xgetopt(argc, argv, optstring)
- Xint argc;
- Xchar *argv[];
- Xchar *optstring;
- X{
- X register char c;
- X register char *place;
- X
- X optarg = NULL;
- X
- X if (scan == NULL || *scan == '\0') {
- X if (optind == 0)
- X optind++;
- X
- X if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
- X return(EOF);
- X if (strcmp(argv[optind], "--")==0) {
- X optind++;
- X return(EOF);
- X }
- X
- X scan = argv[optind]+1;
- X optind++;
- X }
- X
- X c = *scan++;
- X place = strchr(optstring, c);
- X
- X if (place == NULL || c == ':') {
- X fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
- X return('?');
- X }
- X
- X place++;
- X if (*place == ':') {
- X if (*scan != '\0') {
- X optarg = scan;
- X scan = NULL;
- X } else {
- X optarg = argv[optind];
- X optind++;
- X }
- X }
- X
- X return(c);
- X}
- END_OF_FILE
- if test 1552 -ne `wc -c <'getopt.c'`; then
- echo shar: \"'getopt.c'\" unpacked with wrong size!
- fi
- # end of 'getopt.c'
- fi
- if test -f 'gsr.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'gsr.h'\"
- else
- echo shar: Extracting \"'gsr.h'\" \(3157 characters\)
- sed "s/^X//" >'gsr.h' <<'END_OF_FILE'
- X/* gsr.h -- header used with Gnuplot graphics support routines. */
- X#ifndef INCgsr
- X#define INCgsr
- X
- X/*-
- X gnuplot Graphics Support Routines header file. This file is
- X required (needs to be included) by users of the gnuplot Graphics
- X Support library: gsr.c
- X-*/
- X
- X/*
- X Defines required by users of the Gnuplot Graphics Support Routines
- X*/
- X#include <stdio.h>
- X#include <math.h>
- X#ifndef INCgtplot
- X#include "gtplot.h"
- X#endif
- X
- X#ifndef max /* Lattice C has max() in math.h, but shouldn't! */
- X#define max(a,b) ((a > b) ? a : b)
- X#endif
- X
- X#ifndef min
- X#define min(a,b) ((a < b) ? a : b)
- X#endif
- X
- X
- X/* Gnuplot Graphic Support Routine Globals: */
- X
- X/* File pointer being used by the term routines. */
- X#define GSRoutfile GToutfile
- X
- X#ifdef GSR_OWNER
- X
- X/* Define the boundary of the plot
- X * These are computed at each call to gnu_init(), and are constant over
- X * the period of one plot. They must change when the term
- X * type changes (requiring a call to gnu_init()).
- X */
- Xint GSRxleft, GSRxright, GSRybot, GSRytop;
- XBOOLEAN GSRlogx, GSRlogy;
- X
- X/*
- X Value where the yaxis is located (used by IMPULSE lines).
- X*/
- Xint GSRxaxis_y;
- X
- X/*
- X Value of the point and line types in use (especially for gsr_curve())
- X*/
- Xint GSRpoint_type = 0, GSRline_type = 0;
- X
- X/* Boundary and scale factors, in user coordinates */
- Xdouble GSRxmin, GSRxmax, GSRymin, GSRymax;
- Xdouble GSRxscale, GSRyscale;
- Xfloat GSRxtic, GSRytic;
- Xchar *GSRxformat = "%g", *GSRyformat = "%g";
- X#else
- X
- X/*-
- X Gnuplot Graphics Support Routine externals (available while using package):
- X
- X GSRxleft, GSRxright -- location of left, right, top, and bottom sides
- X GSRybot, GSRytop of the plot border in terminal units.
- X
- X GSRlogx, GSRlogy -- flags indicating the x or y dimension is log scale.
- X
- X GSRxaxis_y -- location of the yaxis (used for IMPULSE plotting).
- X
- X GSRpoint_type -- Current point type (usually at least -1 - 6 available)
- X GSRline_type -- Current line type (-2 - 12 on some terminals)
- X
- X GSRxmin, GSRxmax, -- maximum and minimum values expected in user
- X GSRymin, GSRymax coordinates for X and Y coordinates.
- X
- X GSRxscale, -- scaling factors to use to change from user
- X GSRyscale; coordinates back to terminal coordinates.
- X
- X GSRxtic, GSRytic -- tic width in user coordinates.
- X
- X GSRxformat, -- format strings to use with x and y tic values
- X GSRyformat; (default is "%g")
- X-*/
- X
- Xextern int GSRxleft, GSRxright, GSRybot, GSRytop;
- Xextern BOOLEAN GSRlogx, GSRlogy;
- Xextern int GSRxaxis_y;
- Xextern int GSRpoint_type, GSRline_type;
- Xextern double GSRxmin, GSRxmax, GSRymin, GSRymax;
- Xextern double GSRxscale, GSRyscale;
- Xextern float GSRxtic, GSRytic;
- Xextern char *GSRxformat, *GSRyformat;
- X/*- end of GSR external definitions. -*/
- X
- X#endif
- X
- X/*-
- X gsr_map_x(x)
- X Macro to map user coordinate x to screen coordinate.
- X
- X gsr_map_y(y)
- X Macro to map user coordinate y to screen coordinate.
- X
- X These macros map from user to terminal coordinates (maps floating
- X point x or y to screen
- X-*/
- X#define gsr_map_x(x) (int)(GSRxleft+(x-GSRxmin)*GSRxscale+0.5)
- X#define gsr_map_y(y) (int)(GSRybot+(y-GSRymin)*GSRyscale+0.5)
- X
- X#endif
- END_OF_FILE
- if test 3157 -ne `wc -c <'gsr.h'`; then
- echo shar: \"'gsr.h'\" unpacked with wrong size!
- fi
- # end of 'gsr.h'
- fi
- if test -f 'gtplot.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'gtplot.h'\"
- else
- echo shar: Extracting \"'gtplot.h'\" \(1872 characters\)
- sed "s/^X//" >'gtplot.h' <<'END_OF_FILE'
- X#ifndef INCgtplot
- X#define INCgtplot
- X
- X/*-
- X gnuplot Graphics Terminal header file. This file is required by
- X all users of the gnuplot Graphics Terminal library: gterm.c
- X-*/
- X#include "plot.h"
- X
- X/* Some key global variables */
- X#ifdef GT_OWNER
- X/* GTterm_tbl[] is "extern" only in the sense that it is defined later... */
- Xextern struct termentry GTterm_tbl[];
- XFILE *GToutfile=NULL;
- XBOOLEAN GTterm_init=0;
- XBOOLEAN GTinteractive=0; /* Not used correctly yet--who can set it? */
- XBOOLEAN GTcolor=0; /* Not used yet */
- Xint GTterm=0;
- Xfloat GTxsize = 1.0, GTysize = 1.0, GTzsize = 1.0; /* z's not used yet */
- X#else
- X
- X/*-
- X Globals available when using gterm.c:
- X
- X GTterm_tbl[] - table containing function pointers, etc. for all
- X terminal drivers in the gnuplot package.
- X
- X GToutfile - Output file pointer where all plotting activity is
- X written out.
- X
- X GTterm_init - Indicates if the terminal has been initialized yet.
- X
- X GTinteractive - Indicates if we are an interactive terminal or not.
- X
- X GTcolor - Not used yet, someday it would be nice to know if we
- X are working on a color terminal or not.
- X
- X GTterm - Index into GTterm_tbl describing the current terminal.
- X Generally gt_init_teminal() will set this to match the
- X GNUTERM environment variable. The terminal can be
- X changed, however, with gt_change_term().
- X
- X GTxsize, - scaling factors currently only the LaTeX driver can
- X GTysize and the postscript driver make use of these.
- X-*/
- X
- Xextern struct termentry GTterm_tbl[];
- Xextern FILE *GToutfile;
- Xextern BOOLEAN GTterm_init;
- Xextern BOOLEAN GTinteractive;
- Xextern BOOLEAN GTcolor; /* Not used yet */
- Xextern int GTterm;
- Xextern float GTxsize, GTysize;
- X/*--*/
- X
- X/*--*/
- X#endif
- X#endif
- END_OF_FILE
- if test 1872 -ne `wc -c <'gtplot.h'`; then
- echo shar: \"'gtplot.h'\" unpacked with wrong size!
- fi
- # end of 'gtplot.h'
- fi
- if test -f 'gutil.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'gutil.c'\"
- else
- echo shar: Extracting \"'gutil.c'\" \(5062 characters\)
- sed "s/^X//" >'gutil.c' <<'END_OF_FILE'
- X/* GNUPLOT - util.c */
- X/*
- X * Copyright (C) 1986, 1987, 1990, 1991 Thomas Williams, Colin Kelley
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X *
- X * AUTHORS
- X *
- X * Original Software:
- X * Thomas Williams, Colin Kelley.
- X *
- X * Gnuplot 2.0 additions:
- X * Russell Lang, Dave Kotz, John Campbell.
- X *
- X * Gnuplot 3.0 additions:
- X * Gershon Elber and many others.
- X *
- X * Send your comments or suggestions to
- X * pixar!info-gnuplot@sun.com.
- X * This is a mailing list; to join it send a note to
- X * pixar!info-gnuplot-request@sun.com.
- X * Send bug reports to
- X * pixar!bug-gnuplot@sun.com.
- X */
- X
- X#include <ctype.h>
- X#include <setjmp.h>
- X#include <stdio.h>
- X#include <errno.h>
- X#include "plot.h"
- X
- XBOOLEAN screen_ok;
- X /* TRUE if command just typed; becomes FALSE whenever we
- X send some other output to screen. If FALSE, the command line
- X will be echoed to the screen before the ^ error message. */
- X
- X#ifndef vms
- X#ifndef __ZTC__
- Xextern int errno;
- Xextern int sys_nerr;
- Xextern char *sys_errlist[];
- X#endif
- X#endif /* vms */
- X
- Xextern char input_line[];
- Xextern struct lexical_unit token[];
- Xextern jmp_buf env; /* from plot.c */
- Xextern int inline_num; /* from command.c */
- Xextern BOOLEAN interactive; /* from plot.c */
- Xextern char *infile_name; /* from plot.c */
- Xextern int c_token, num_tokens;
- X
- Xextern char *strchr();
- X
- X#ifndef AMIGA_AC_5
- Xextern double sqrt(), atan2();
- X#endif
- X
- X
- X/*
- X * equals() compares string value of token number t_num with str[], and
- X * returns TRUE if they are identical.
- X */
- Xequals(t_num, str)
- Xint t_num;
- Xchar *str;
- X{
- Xregister int i;
- X
- X if (!token[t_num].is_token)
- X return(FALSE); /* must be a value--can't be equal */
- X for (i = 0; i < token[t_num].length; i++) {
- X if (input_line[token[t_num].start_index+i] != str[i])
- X return(FALSE);
- X }
- X /* now return TRUE if at end of str[], FALSE if not */
- X return(str[i] == '\0');
- X}
- X
- X
- X
- X/*
- X * almost_equals() compares string value of token number t_num with str[], and
- X * returns TRUE if they are identical up to the first $ in str[].
- X */
- Xalmost_equals(t_num, str)
- Xint t_num;
- Xchar *str;
- X{
- Xregister int i;
- Xregister int after = 0;
- Xregister start = token[t_num].start_index;
- Xregister length = token[t_num].length;
- X
- X if (!token[t_num].is_token)
- X return(FALSE); /* must be a value--can't be equal */
- X for (i = 0; i < length + after; i++) {
- X if (str[i] != input_line[start + i]) {
- X if (str[i] != '$')
- X return(FALSE);
- X else {
- X after = 1;
- X start--; /* back up token ptr */
- X }
- X }
- X }
- X
- X /* i now beyond end of token string */
- X
- X return(after || str[i] == '$' || str[i] == '\0');
- X}
- X
- X
- X
- Xisstring(t_num)
- Xint t_num;
- X{
- X
- X return(token[t_num].is_token &&
- X (input_line[token[t_num].start_index] == '\'' ||
- X input_line[token[t_num].start_index] == '\"'));
- X}
- X
- X
- X/*
- X * quote_str() does the same thing as copy_str, except it ignores the
- X * quotes at both ends. This seems redundant, but is done for
- X * efficency.
- X */
- Xquote_str(str, t_num)
- Xchar str[];
- Xint t_num;
- X{
- Xregister int i = 0;
- Xregister int start = token[t_num].start_index + 1;
- Xregister int count;
- X
- X if ((count = token[t_num].length - 2) > MAX_ID_LEN)
- X count = MAX_ID_LEN;
- X if (count>0) {
- X do {
- X str[i++] = input_line[start++];
- X } while (i != count);
- X }
- X str[i] = '\0';
- X}
- X
- X
- X/*
- X * capture() copies into str[] the part of input_line[] which lies between
- X * the begining of token[start] and end of token[end].
- X */
- Xcapture(str,start,end)
- Xchar str[];
- Xint start,end;
- X{
- Xregister int i,e;
- X
- X e = token[end].start_index + token[end].length;
- X for (i = token[start].start_index; i < e && input_line[i] != '\0'; i++)
- X *str++ = input_line[i];
- X *str = '\0';
- X}
- X
- X
- Xconvert(val_ptr, t_num)
- Xstruct value *val_ptr;
- Xint t_num;
- X{
- X *val_ptr = token[t_num].l_val;
- X}
- X
- X
- Xstatic char *num_to_str(r)
- Xdouble r;
- X{
- X static i = 0;
- X static char s[4][20];
- X int j = i++;
- X
- X if ( i > 3 ) i = 0;
- X
- X sprintf( s[j], "%g", r );
- X if ( strchr( s[j], '.' ) == NULL &&
- X strchr( s[j], 'e' ) == NULL &&
- X strchr( s[j], 'E' ) == NULL )
- X strcat( s[j], ".0" );
- X
- X return s[j];
- X}
- X
- X
- X
- Xdouble
- Xreal(val) /* returns the real part of val */
- Xstruct value *val;
- X{
- X switch(val->type) {
- X case INT:
- X return((double) val->v.int_val);
- X case CMPLX:
- X return(val->v.cmplx_val.real);
- X }
- X int_error("unknown type in real()",NO_CARET);
- X /* NOTREACHED */
- X return((double)0.0);
- X}
- X
- Xstruct value *
- Xconst_express(valptr)
- Xstruct value *valptr;
- X{
- X if (END_OF_COMMAND)
- X int_error("constant expression required",c_token);
- X
- X/* Cheap imitation, assume there is a well-formed value to avoid evaluate_at */
- X convert(valptr, c_token);
- X
- X return(valptr);
- X}
- END_OF_FILE
- if test 5062 -ne `wc -c <'gutil.c'`; then
- echo shar: \"'gutil.c'\" unpacked with wrong size!
- fi
- # end of 'gutil.c'
- fi
- if test -f 'makefile.3b1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.3b1'\"
- else
- echo shar: Extracting \"'makefile.3b1'\" \(3044 characters\)
- sed "s/^X//" >'makefile.3b1' <<'END_OF_FILE'
- X
- X#
- X# GNUPLOT Makefile for ATT 3b1 (ATT 7300 or the "unix-PC")
- X#
- X# Note: this makefile uses the shared library
- X#
- X
- X# directory where to install executables on 'make install'
- XDEST=/usr/local/lib
- X# directory for installing man page on 'make man_install'
- X# Well, man page needs to be generated out of source code for library
- X# somehow...
- XMANDEST=/usr/man/manl
- X
- X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
- X# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
- X# -DNOCOPY if you don't have a memcpy() by any name
- X# -O if you trust your compiler's optimizer
- XCC = cc
- X
- XCFLAGS = -g
- X
- X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
- X# -DAED AED 512 and AED 767
- X# -DAPOLLO Apollo workstations
- X# -DBITGRAPH BBN BitGraph
- X# -DDXY800A Roland DXY800A plotter
- X# -DEPSON Epson LX-800, Star NL-10, NX-1000 and lots of others
- X# -DFIG Fig graphics language (requires object.h from TransFig)
- X# -DHP2648 HP2648, HP2647
- X# -DHP26 HP2623A and maybe others
- X# -DHP75 HP7580, and probably other HPs
- X# -DHPGL HP7475 and (hopefully) lots of others
- X# -DHPLJET HP Laserjet
- X# -DIMAGEN Imagen laser printers (300dpi) (requires -Iterm also)
- X# -DIRIS4D IRIS4D series computer
- X# -DKERMIT MS-Kermit Tektronix 4010 emulator
- X# -DLATEX LATEX picture environment
- X# -DPOSTSCRIPT Postscript
- X# -DPROPRINTER IBM Proprinter
- X# -DQMS QMS/QUIC laserprinter (Talaris 1200 and others)
- X# -DREGIS ReGis graphics (vt125, vt220, vt240, Gigis...)
- X# -DSELANAR Selanar
- X# -DTEK Tektronix 4010, and probably others
- X# -DSUN Sun Microsystems Workstation
- X# -DUNIXPC unixpc (ATT 3b1 or ATT 7300)
- X# -DUNIXPLOT unixplot
- X# -DV384 Vectrix 384 and tandy color printer
- X
- XTERMFLAGS = -I../term -DHPLJET -DNEC -DUNIXPC
- X#TERMFLAGS = -I../term -DHPLJET -DNEC -DUNIXPLOT -DUNIXPC
- X#TERMFLAGS = -I../term -DUNIXPC
- X
- X# These object files form the gplotlib.ar library
- XOBJS = gsr.o gterm.o
- X
- X# -lplot iff you have -DUNIXPLOT
- X# -lsuntool -lsunwindow -lpixrect iff you have -DSUN
- X# -lgl_s if IRIS4D
- XLIBS = -lm -lplot
- X
- Xbar: $(OBJS) bar.o
- X ld /lib/crt0s.o /lib/shlib.ifile bar.o $(OBJS) $(LIBS) -o bar
- X
- Xbars: $(OBJS) bars.o
- X ld /lib/crt0s.o /lib/shlib.ifile bars.o $(OBJS) $(LIBS) -o bars
- X
- Xpie: $(OBJS) pie.o
- X ld /lib/crt0s.o /lib/shlib.ifile pie.o $(OBJS) $(LIBS) -o pie
- X
- Xall: bar pie
- X
- Xgterm.o: ../term/*.trm gterm.c
- X $(CC) $(CFLAGS) $(TERMFLAGS) -c gterm.c
- X
- X$(OBJS): gtplot.h gsr.h
- X
- Xclean:
- X rm -f *.o *~ ../term/*~ *.*_doc
- X
- Xspotless:
- X rm -f *.o *~ ../term/*~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc
- X
- Xdoc: docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
- X docu <gsr.c >gsr.c_doc
- X docu <gsr.h >gsr.h_doc
- X docu <gterm.c >gterm.c_doc
- X docu <gtplot.h >gtplot.h_doc
- X cpr -ac -C -PBACKSPACE \
- X intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
- X rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc
- X
- Xdocu: docu.c
- X cc docu.c -o docu
- X
- Xcpr: cpr.c
- X cc cpr.c -o cpr
- X
- END_OF_FILE
- if test 3044 -ne `wc -c <'makefile.3b1'`; then
- echo shar: \"'makefile.3b1'\" unpacked with wrong size!
- fi
- # end of 'makefile.3b1'
- fi
- if test -f 'makefile.ult' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.ult'\"
- else
- echo shar: Extracting \"'makefile.ult'\" \(3338 characters\)
- sed "s/^X//" >'makefile.ult' <<'END_OF_FILE'
- X#
- X# GPLOTLIB Makefile for Ultrix
- X#
- X# Note: Ultrix standard cc compiler has a bug with static structure
- X# initializations [such as struct ts {int x;} tb[]={{100*0.32}};]
- X# and so this makefile uses vcc instead. If this isn't possible,
- X# and you get "line xx: illegal initialization", then you'll have
- X# to go into the .trm include file and compute all the floating point
- X# defines with a calculator.
- X
- X
- X# directory where to install executables on 'make install'
- XDEST=/usr/local/lib
- X# directory for installing man page on 'make man_install'
- X# Well, man page needs to be generated out of source code for library
- X# somehow...
- XMANDEST=/usr/man/manl
- X
- X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
- X# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
- X# -DNOCOPY if you don't have a memcpy() by any name
- X# -O if you trust your compiler's optimizer
- XCC = cc
- X
- XCFLAGS = -DBCOPY -DBZERO -O #-gx
- X
- X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
- X# -DAED AED 512 and AED 767
- X# -DAPOLLO Apollo workstations
- X# -DBITGRAPH BBN BitGraph
- X# -DDXY800A Roland DXY800A plotter
- X# -DEPSON Epson LX-800, Star NL-10, NX-1000 and lots of others
- X# -DFIG Fig graphics language (requires object.h from TransFig)
- X# -DHP2648 HP2648, HP2647
- X# -DHP26 HP2623A and maybe others
- X# -DHP75 HP7580, and probably other HPs
- X# -DHPGL HP7475 and (hopefully) lots of others
- X# -DHPLJET HP Laserjet
- X# -DIMAGEN Imagen laser printers (300dpi) (requires -Iterm also)
- X# -DIRIS4D IRIS4D series computer
- X# -DKERMIT MS-Kermit Tektronix 4010 emulator
- X# -DLATEX LATEX picture environment
- X# -DPOSTSCRIPT Postscript
- X# -DPROPRINTER IBM Proprinter
- X# -DQMS QMS/QUIC laserprinter (Talaris 1200 and others)
- X# -DREGIS ReGis graphics (vt125, vt220, vt240, Gigis...)
- X# -DSELANAR Selanar
- X# -DTEK Tektronix 4010, and probably others
- X# -DSUN Sun Microsystems Workstation
- X# -DUNIXPC unixpc (ATT 3b1 or ATT 7300)
- X# -DUNIXPLOT unixplot
- X# -DV384 Vectrix 384 and tandy color printer
- X
- X# -DEPSON removed just before HP2648.
- X
- XTERMFLAGS = -I../term -DAED -DBITGRAPH -DDXY800A -DHP2648 \
- X -DHP26 -DHP75 -DHPGL -DHPLJET -DIMAGEN -DKERMIT -DLATEX \
- X -DPOSTSCRIPT -DPROPRINTER -DQMS -DREGIS -DSELANAR -DTEK \
- X -DUNIXPLOT -DV384
- X
- X# These object files form the gplotlib.ar library
- XOBJS = gsr.o gterm.o
- X
- X# -lplot iff you have -DUNIXPLOT
- X# -lsuntool -lsunwindow -lpixrect iff you have -DSUN
- X# -lgl_s if IRIS4D
- XLIBS = -lm -lplot
- X
- Xbar: $(OBJS) bar.o
- X vcc bar.o $(OBJS) $(LIBS) -o bar
- X
- Xbars: $(OBJS) bars.o
- X vcc bars.o $(OBJS) $(LIBS) -o bar
- X
- Xpie: $(OBJS) pie.o
- X vcc pie.o $(OBJ) $(LIBS) -o bar
- X
- Xall: bar pie
- X
- Xgterm.o: ../term/*.trm gterm.c
- X vcc $(CFLAGS) $(TERMFLAGS) -c gterm.c
- X
- X$(OBJS): gtplot.h gsr.h
- X
- Xclean:
- X rm -f *.o *~ *.*_doc
- X
- Xspotless:
- X rm -f *.o *~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc
- X
- Xdoc: docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
- X docu <gsr.c >gsr.c_doc
- X docu <gsr.h >gsr.h_doc
- X docu <gterm.c >gterm.c_doc
- X docu <gtplot.h >gtplot.h_doc
- X cpr -ac -C -PBACKSPACE \
- X intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
- X rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc
- X
- Xdocu: docu.c
- X cc docu.c -o docu
- X
- Xcpr: cpr.c
- X cc cpr.c -o cpr
- END_OF_FILE
- if test 3338 -ne `wc -c <'makefile.ult'`; then
- echo shar: \"'makefile.ult'\" unpacked with wrong size!
- fi
- # end of 'makefile.ult'
- fi
- if test -f 'makefile.unx' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.unx'\"
- else
- echo shar: Extracting \"'makefile.unx'\" \(2639 characters\)
- sed "s/^X//" >'makefile.unx' <<'END_OF_FILE'
- X#
- X# GPLOTLIB Makefile for Unix machines
- X#
- X
- X# -DBCOPY if your memcpy() is called bcopy() (a Berkeleyism, right?)
- X# -DBZERO if you need to use bzero() (another BSD feature) instead of memset()
- X# -DNOCOPY if you don't have a memcpy() by any name
- X# -O if you trust your compiler's optimizer
- XCC = cc
- X
- XCFLAGS = -I.. -DBCOPY -DBZERO -O #-gx
- X
- X# -D<terminal> in TERMFLAGS iff you wish to support <terminal>
- X# -DAED AED 512 and AED 767
- X# -DAPOLLO Apollo workstations
- X# -DBITGRAPH BBN BitGraph
- X# -DDXY800A Roland DXY800A plotter
- X# -DEPSON Epson LX-800, Star NL-10, NX-1000 and lots of others
- X# -DFIG Fig graphics language (requires object.h from TransFig)
- X# -DHP2648 HP2648, HP2647
- X# -DHP26 HP2623A and maybe others
- X# -DHP75 HP7580, and probably other HPs
- X# -DHPGL HP7475 and (hopefully) lots of others
- X# -DHPLJET HP Laserjet
- X# -DIMAGEN Imagen laser printers (300dpi) (requires -Iterm also)
- X# -DIRIS4D IRIS4D series computer
- X# -DKERMIT MS-Kermit Tektronix 4010 emulator
- X# -DLATEX LATEX picture environment
- X# -DPOSTSCRIPT Postscript
- X# -DPROPRINTER IBM Proprinter
- X# -DQMS QMS/QUIC laserprinter (Talaris 1200 and others)
- X# -DREGIS ReGis graphics (vt125, vt220, vt240, Gigis...)
- X# -DSELANAR Selanar
- X# -DTEK Tektronix 4010, and probably others
- X# -DSUN Sun Microsystems Workstation
- X# -DUNIXPC unixpc (ATT 3b1 or ATT 7300)
- X# -DUNIXPLOT unixplot
- X# -DV384 Vectrix 384 and tandy color printer
- X
- X# -DEPSON removed just before HP2648.
- X
- XTERMFLAGS = -I.. -I../term -DUNIXPLOT
- X
- X# These object files form the gplotlib.ar library
- XOBJS = gsr.o bitmap.o gterm.o
- X
- X# -lplot iff you have -DUNIXPLOT
- X# -lsuntool -lsunwindow -lpixrect iff you have -DSUN
- X# -lgl_s if IRIS4D
- XLIBS = -lm -lplot
- X
- Xbar: $(OBJS) bar.o
- X cc bar.o $(OBJS) $(LIBS) -o bar
- X
- Xbars: $(OBJS) bars.o
- X cc bars.o $(OBJS) $(LIBS) -o bar
- X
- Xpie: $(OBJS) pie.o
- X cc pie.o $(OBJ) $(LIBS) -o bar
- X
- Xall: bar pie
- X
- Xgterm.o: ../term/*.trm gterm.c
- X cc $(CFLAGS) $(TERMFLAGS) -c gterm.c
- X
- Xbitmap.o: ../bitmap.c
- X cc $(CFLAGS) -c ../bitmap.c
- X
- X$(OBJS): gtplot.h gsr.h
- X
- Xclean:
- X rm -f *.o *~ *.*_doc
- X
- Xspotless:
- X rm -f *.o *~ TAGS bar bars pie cpr docu *.*_doc gplotlib.doc
- X
- Xdoc: docu cpr intro.doc gsr.c gsr.h gterm.c gtplot.h
- X docu <gsr.c >gsr.c_doc
- X docu <gsr.h >gsr.h_doc
- X docu <gterm.c >gterm.c_doc
- X docu <gtplot.h >gtplot.h_doc
- X cpr -ac -C -PBACKSPACE \
- X intro.doc gterm.c_doc gtplot.h_doc gsr.c_doc gsr.h_doc >gplotlib.doc
- X rm -f gsr.c_doc gsr.h_doc gterm.c_doc gtplot.h_doc
- X
- Xdocu: docu.c
- X cc docu.c -o docu
- X
- Xcpr: cpr.c
- X cc cpr.c -o cpr
- END_OF_FILE
- if test 2639 -ne `wc -c <'makefile.unx'`; then
- echo shar: \"'makefile.unx'\" unpacked with wrong size!
- fi
- # end of 'makefile.unx'
- fi
- echo shar: End of archive 1 \(of 5\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-